package com.hut.oa.model.bean;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * 讨论区
 * @author 郑单单
 *
 */
@Entity
@Table(name="discuss_area")
public class DiscussArea {
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="da_id")
	private Long id;//讨论id
	
	@Column(name="da_type",nullable=false)
	private Integer type=0;//类型id
	
	@Column(name="da_status",nullable=false)
	private Integer status=0;//状态id
	
	@Column(name="da_title")
	private String title;//标题
	
	@Column(name="da_content")
	private String content;//内容
	
	@Column(name="da_push_time")
	private Date pushTime=new Date();//发布时间
	
	@Column(name="da_new_time")
	private Date newTime=new Date();//最后编辑时间
	
	@Column(name="da_comment_num")
	private Integer commentNum=0;//评论数
	
	@OneToMany(mappedBy="discuss",fetch=FetchType.LAZY,cascade=CascadeType.ALL)
	private List<DiscussComment> disComments;//对应多个帖子评价
	
	@ManyToOne()
	@JoinColumn(name="da_user_id",nullable=false)
	private User user;//对应用户
	
	@Transient
	private DiscussArea discuss;//帖子
	
	public DiscussArea() {}
	
	
	public Integer getCommentNum() {
		return commentNum;
	}


	public void setCommentNum(Integer commentNum) {
		this.commentNum = commentNum;
	}


	public DiscussArea getDiscuss() {
		return discuss;
	}

	public void setDiscuss(DiscussArea discuss) {
		this.discuss = discuss;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public List<DiscussComment> getDisComments() {
		return disComments;
	}

	public void setDisComments(List<DiscussComment> disComments) {
		this.disComments = disComments;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Integer getType() {
		return type;
	}


	public void setType(Integer type) {
		this.type = type;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getPushTime() {
		return pushTime;
	}

	public void setPushTime(Date pushTime) {
		this.pushTime = pushTime;
	}

	public Date getNewTime() {
		return newTime;
	}

	public void setNewTime(Date newTime) {
		this.newTime = newTime;
	}

	@Override
	public String toString() {
		return "DiscussArea [id=" + id + ", type=" + type + ", status=" + status + ", title=" + title + ", content="
				+ content + ", pushTime=" + pushTime + ", newTime=" + newTime + ", commentNum=" + commentNum
				+ ", disComments=" + disComments + "]";
	}

}
